﻿(function ($) {
    $.extend($,
        {
            AjaxMsgData: function (data, funSuccess, funError) {
                if (!data || !data.Statu) {
                    return;
                }
                switch (data.Statu) {
                    case "OK":
                    case "Success":
                        if (data.Msg && data.Msg.trim() != "") {
                            $.alertMsg("系统提示", data.Statu + ":" + data.Msg, function () { if (funSuccess) funSuccess(data); }, "green", "icon-ok-sign", "300px");
                        }
                        else { if (funSuccess) funSuccess(data); }
                        break;

                    case "Error":
                    case "Failure":
                        if (data.Msg && data.Msg.trim() != "") {
                            $.alertMsg("系统提示", data.Statu + ":" + data.Msg, function () { if (funError) funError(data); }, "red", "icon-remove-sign", "300px");
                        }
                        else { if (funError) funError(data); }
                        break;

                    case "UnLogin":
                        $.alertMsg("系统提示", data.Statu + ":" + data.Msg, function () { if (window.top) window.top.location = data.BackUrl; else window.location = data.BackUrl; }, "yellow", "icon-warning-sign", "300px");
                        break;
                }
            },
            alertMsg: function (title, msg, func, type, icon, width) {
                $.alert({
                    type: type,
                    title: title,
                    content: msg,
                    icon: icon,
                    onAction: function () {
                        if (func) {
                            func();
                        }
                    },
                    boxWidth: width,
                    useBootstrap: false,
                });
            }
        });
}(jQuery));